﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Write.ascx.cs" Inherits="Framework.Portal.Layouts.Client.Components.Teenio.Write" %>
<div class="col2">
    <div class="guibai">
        <h1 class="title_event">
            Gủi bài</h1>
        <table width="505" border="1" cellpadding="0" cellspacing="0" class="formguibai">
            <tr>
                <td width="110">
                    Tiêu đề *
                </td>
                <td width="395">
                    <asp:TextBox ID="txtTitle" runat="server" style="width: 300px;" class="textbox "></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Chuyên mục*
                </td>
                <td style="line-height: 30px">
                    <asp:DropDownList ID="drpCategory" runat="server" class="textbox" style="width: 300px;" on>
                        <asp:ListItem Text="Không thể thao tác dữ liệu" Value="0"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td>
                    <asp:RadioButton ID="chkSangtac" GroupName="checkType" runat="server" Checked="true" Text="Sáng tác" onclick="ShowSource(0);" />
                    <asp:RadioButton ID="chkSuutam" GroupName="checkType" runat="server" Text="Sưu tầm" onclick="ShowSource(1);" />                                          
                    <div id="boxSource" style="display:none; margin-top:10px;">
                        <asp:TextBox ID="txtSource" runat="server" style="width: 300px;" Text="Ghi rõ nguồn" class="textbox" onfocus="if (this.value=='Ghi rõ nguồn') this.value='';" onblur="if (this.value=='') this.value='Ghi rõ nguồn';"></asp:TextBox>
                    </div></td>
            </tr>
            <tr>
                <td>
                    <asp:Image runat="server" ID="filepath_image" style="border-width:0px;" />
                </td>
                <td>
                    <span id="spanButtonImagePlaceHolder"></span>
                    <asp:HiddenField ID="filepath_image_hidden" runat="server" />
                    
                <div class="paddingleft10" style="display:none">
                    <button id="btnCancel" type="button">
                        Cancel all uploads</button>                                          
                </div> 
                <div class="fieldset flash" id="fsUploadImageProgress" style="display:none">
                    <span class="legend">Upload queue</span>
                </div>
                    <div id="divLoadingContent" class="content" style="background-color: #FFFF66; border-top: solid 4px #FF9966;
                    border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;">
                    SWFUpload is loading. Please wait a moment...
                </div>
                <div id="divLongLoading" class="content" style="background-color: #FFFF66; border-top: solid 4px #FF9966;
                    border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;">
                    SWFUpload is taking a long time to load or the load has failed. Please make sure
                    that the Flash Plugin is enabled and that a working version of the Adobe Flash Player
                    is installed.
                </div>
                <div id="divAlternateContent" class="content" style="background-color: #FFFF66; border-top: solid 4px #FF9966;
                    border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;">
                    We're sorry. SWFUpload could not load. You may need to install or upgrade Flash
                    Player. Visit the <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">
                        Adobe website</a> to get the Flash Player.
                </div>
                </td>
            </tr>
            <tr>
                <td>
                    Nội dung
                </td>
                <td>
                    <textarea id="txtRawContent" runat="server" rows="15" cols="80" style="width:100%;"></textarea>
                </td>
            </tr>
            <tr id="boxUpload">
                <td>
                    Upload audio
                </td>
                <td>                    
                    <span id="spanButtonAudioPlaceHolder"></span>   
                    &nbsp;<asp:TextBox ID="filepath_media" runat="server" style="width: 250px; margin: 0 10px 0 0" class="textbox "></asp:TextBox>
                    <asp:HiddenField ID="filepath_media_hidden" runat="server" />              
                    <div class="fieldset flash" id="fsUploadAudioProgress" style="display:none">
                        <span class="legend">Upload queue</span>
                    </div>

                    
                </td>
            </tr>
            <asp:Panel ID="pnlEvent" runat="server">
            <tr>
                <td>&nbsp;</td>
                <td>
                    <asp:CheckBox ID="chkEvent" runat="server" Text="Tham gia sự kiện 'Teenio idol'" /></td>
            </tr>
            </asp:Panel>
            <tr>
                <td>
                    &nbsp;
                </td>
                <td align="right">
                    <asp:Button ID="btnFinish" runat="server" Text="Hoàn tất" CssClass="btn_xanh" OnClick="btnFinish_Click" />
                    <asp:Button ID="btnReset" runat="server" Text="Hủy bỏ" CssClass="btn_xanh" OnClick="btnCancel_Click" />
                </td>
            </tr>
        </table>
    </div>
    <div class="chitiethuongdan">
        <h1 class="title_event" onclick="openFileBrowser('ctl09_ctl03_txtTitle','all')">
            Lưu ý khi gửi bài</h1>
        <p>
            <b>-Đối với bài sáng tác dạng text sưu tầm được đăng tải trên Teenio sẽ được tính như
                sau:</b></p>
        <p>
            + Mỗi thành viên có 20 bài sưu tầm dạng text up lên Teenio được cộng 1*</p>
        <b>- Đối với bài sáng tác dạng text sưu tầm được đăng tải trên Teenio sẽ được tính như
            sau:</b>
        <p>
            + Mỗi thành viên có 20 bài sưu tầm dạng text up lên Teenio được cộng 1*</p>
        <p>
            + Mỗi thành viên có 30 bài sưu tầm dạng text up lên Teenio được cộng 2*</p>
        <p>
            + Mỗi thành viên có 40 bài sưu tầm dạng text up lên Teenio được cộng 3*</p>
        <p>
            + Mỗi thành viên có 50 bài sưu tầm dạng text up lên Teenio được cộng 4*</p>
        <p>
            - Với những <b>thành viên kim cương</b> của Teenio sẽ được <b>nghe truyện của Teenio
                miễn phí</b></p>
        <p>
            - <b>Thành viên Vàng</b> tính như sau: <b>Là thành viên có số * (sao) từ 4 - 7* (Sao)</b></p>
        <p>
            - <b>Thành viên Kim cương</b> là những <b>thành viên có số * (sao) từ 8* trở lên</b></p>
    </div>
    <br class="clear" />
</div>
<!--************* end:col2 *************-->
<script type="text/javascript" src="/Resource/Javascript/filemanager/swfupload/swfupload.min.js"></script>
<script type="text/javascript" src="/Resource/Javascript/filemanager/swfupload/plugins/swfupload.queue.js"></script>
<script type="text/javascript" src="/Resource/Javascript/filemanager/swfupload/fileprogress.js"></script>
<script type="text/javascript" src="/Resource/Javascript/filemanager/swfupload/handlers.js"></script>
<script type="text/javascript">
    var swfuImage;
    var swfuAudio;
    $(document).ready(function () {
        var initEditor = function () {
            $("#<%= txtRawContent.ClientID %>").sceditorBBCodePlugin({
                toolbar: "bold,italic,underline,|,font,size,color,removeformat,|,image,emoticon,|,source",
                style: "/ClientScript/sceditor/css/jquery.sceditor.default.min.css"
            });
        };
        initEditor();
        var ChangeType = function (value) {
            type = value.split('|')[0];
            if (type == "0")
                $("#boxUpload").hide();
            else
                $("#boxUpload").show();
        };
        $('#<%= drpCategory.ClientID %>').change(function () {
            ChangeType($(this).attr('value'));
        });
        ChangeType($("#<%= drpCategory.ClientID %> option:selected").val());
    });
    function openFileBrowser(id, type) {
        if(type == "image")
            fileBrowserlink = "/Popup.aspx?p=3&l=vi-vn&c=1102&editor=standalone&filter=image&source=img&returnID=" + id;
        else
            fileBrowserlink = "/Popup.aspx?p=3&l=vi-vn&c=1102&editor=standalone&source=text&returnID=" + id;
        window.open(fileBrowserlink, 'pdwfilebrowser', 'width=1000,height=650,scrollbars=no,toolbar=no,location=no');
    }
    function ShowSource(type) {
        if (type == 0)
            $("#boxSource").hide();
        else
            $("#boxSource").show();
    }
    function validatePostEntry(doPost, params) {
        var isValidate = true;
        if (!ValidateControls("Vui lòng nhập tiêu đề bài viết!", "<%= txtTitle.ClientID %>")) {
            isValidate = false;
        }
        if ($('#<%= filepath_image_hidden.ClientID %>').val() == '') {
            confirm("Bạn chưa nhập ảnh đại diện, sử dụng ảnh mặc định ?");         
            isValidate = false;
        }
        else {
            var checkimg = $('#<%= filepath_image_hidden.ClientID %>').val();
            var mEs = checkimg.match(/([^\s]+(?=\.(jpg|gif|png|bmp|JPG|GIF|PNG|BMP))\.\2)/gm), len = (mEs != null) ? mEs.length : 0;
            if (len < 1) {
                alert("Ảnh không hợp lệ!");
                isValidate = false;
            }
        }
        return isValidate;
    }
    function ValidateControls(valid_message, valid_id) {
        var valid_obj = $("#" + valid_id).val();
        if (valid_obj == null || valid_obj == '') {
            alert(valid_message);
            $("#" + valid_id).focus();
            return false;
        }
        return true;
    }
    function fileQueued(file) {        
            $("#fsUploadImageProgress").show();
        }
    function uploadSuccess(file, serverData, responseReceived) {
            document.getElementById("<%= filepath_image_hidden.ClientID %>").value = "<%= uploadPath %>" + serverData;
            $("#<%= filepath_image.ClientID %>").attr("src", "/Resources.ashx?module=viewimage&h=50&w=50&far=1&src=" + encodeURIComponent("<%= uploadPath %>" + serverData) + "&bg=0000FF");
    }
    function uploadComplete(file) {
        $("#fsUploadImageProgress").hide();
    }

    function fileQueuedAudio(file) {
        $("#fsUploadAudioProgress").show();
    }
    function uploadSuccessAudio(file, serverData, responseReceived) {
        document.getElementById("<%= filepath_media_hidden.ClientID %>").value = "<%= uploadPath %>" + serverData;
        $("#<%= filepath_media.ClientID %>").val("<%= uploadPath %>" + serverData);
    }
    function uploadCompleteAudio(file) {
        $("#fsUploadAudioProgress").hide();
    }

    var settingsImage = {
        flash_url: "Resource/Javascript/filemanager/swfupload/swfupload.swf",
        upload_url: "/Resources.ashx?module=popup&action=do_upload",
        post_params: {
            "PHPSESSID": "<%=Session.SessionID %>",
            "uploadpath": "<%= uploadPath %>"
        },
        file_size_limit: "50 MB",
        file_types: "<%= extension_imagelist %>",
        file_types_description: "Media Files",
        file_upload_limit: 1,
        file_queue_limit: 0,
        custom_settings: {
            progressTarget: "fsUploadImageProgress",
            cancelButtonId: "btnCancel"
        },
        debug: false,

        // Button settings
        button_width: "175",
        button_height: "20",
        button_window_mode: "transparent",
        button_placeholder_id: "spanButtonImagePlaceHolder",
        button_text: '<span class="browseButton">Chọn ảnh đại diện...</span>',
        button_text_style: ".browseButton {font-family:sans-serif; color:#000000; font-size:12px; font-weight: bold;}",
        button_cursor: SWFUpload.CURSOR.HAND,
        button_text_top_padding: 1,

        // The event handler functions are defined in handlers.js
        swfupload_loaded_handler: swfUploadLoaded,
        file_queued_handler: fileQueued,
        file_queue_error_handler: fileQueueError,
        file_dialog_complete_handler: fileDialogComplete,
        upload_start_handler: uploadStart,
        upload_progress_handler: uploadProgress,
        upload_error_handler: uploadError,
        upload_success_handler: uploadSuccess,
        upload_complete_handler: uploadComplete,
        queue_complete_handler: queueComplete, // Queue plugin event

        // SWFObject settings
        minimum_flash_version: "9.0.28",
        swfupload_pre_load_handler: swfUploadPreLoad,
        swfupload_load_failed_handler: swfUploadLoadFailed
    };
    var settingsAudio = {
        flash_url: "Resource/Javascript/filemanager/swfupload/swfupload.swf",
        upload_url: "/Resources.ashx?module=popup&action=do_upload",
        post_params: {
            "PHPSESSID": "<%=Session.SessionID %>",
            "uploadpath": "<%= uploadPath %>"
        },
        file_size_limit: "50 MB",
        file_types: "<%= extension_audiolist %>",
        file_types_description: "Media Files",
        file_upload_limit: 1,
        file_queue_limit: 0,
        custom_settings: {
            progressTarget: "fsUploadAudioProgress",
            cancelButtonId: "btnCancel"
        },
        debug: false,

        // Button settings
        button_width: "120",
        button_height: "20",
        button_window_mode: "transparent",
        button_placeholder_id: "spanButtonAudioPlaceHolder",
        button_text: '<span class="browseButton">Chọn Audio...</span>',
        button_text_style: ".browseButton {font-family:sans-serif; color:#000000; font-size:12px; font-weight: bold;}",
        button_cursor: SWFUpload.CURSOR.HAND,
        button_text_top_padding: 1,

        // The event handler functions are defined in handlers.js
        swfupload_loaded_handler: swfUploadLoaded,
        file_queued_handler: fileQueuedAudio,
        file_queue_error_handler: fileQueueError,
        file_dialog_complete_handler: fileDialogComplete,
        upload_start_handler: uploadStart,
        upload_progress_handler: uploadProgress,
        upload_error_handler: uploadError,
        upload_success_handler: uploadSuccessAudio,
        upload_complete_handler: uploadCompleteAudio,
        queue_complete_handler: queueComplete, // Queue plugin event

        // SWFObject settings
        minimum_flash_version: "9.0.28",
        swfupload_pre_load_handler: swfUploadPreLoad,
        swfupload_load_failed_handler: swfUploadLoadFailed
    };
    swfuImage = new SWFUpload(settingsImage);
    swfuAudio = new SWFUpload(settingsAudio);
</script>